"""
config.json 的类型定义
"""
from typing import TypedDict, List
try:
    from typing import NotRequired
except ImportError:
    from typing_extensions import NotRequired


class RootCAConfig(TypedDict):
    """根 CA 证书配置"""
    output_dir: str
    key_path: str
    crt_path: str
    password: str
    country_name: str
    state_or_province_name: str
    locality_name: str
    organization_name: str
    common_name: str
    days: int
    key_size: NotRequired[int]  # RSA密钥长度，默认4096


class IntermediateCAConfig(TypedDict):
    """中间 CA 证书配置"""
    root_key_path: str
    root_crt_path: str
    root_password: str
    password: str
    output_dir: str
    key_path: str
    crt_path: str
    country_name: str
    state_or_province_name: str
    locality_name: str
    organization_name: str
    common_name: str
    days: int
    key_size: NotRequired[int]  # RSA密钥长度，默认4096


class ServerCertConfig(TypedDict):
    """服务器证书配置"""
    inter_key_path: str
    inter_crt_path: str
    inter_password: str
    root_crt_path: str
    output_dir: str
    key_path: str
    crt_path: str
    fullchain: str
    country_name: str
    state_or_province_name: str
    locality_name: str
    organization_name: str
    common_name: str
    dns_names: List[str]
    ip_addrs: List[str]
    days: int
    key_size: NotRequired[int]  # RSA密钥长度，默认2048


class ConfigDict(TypedDict):
    """完整的配置文件类型"""
    root_path: str
    root_ca: NotRequired[RootCAConfig]
    intermediate_ca: NotRequired[List[IntermediateCAConfig]]
    server_cert: NotRequired[List[ServerCertConfig]]

